package com.usian.behavior.controller.v1;

import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.usian.apis.behavior.ApLikesBehaviorControllerApi;
import com.usian.apis.behavior.ApUnLikesBehaviorControllerApi;
import com.usian.behavior.service.ApLikesBehaviorService;
import com.usian.behavior.service.ApUnLikesBehaviorService;
import com.usian.model.behavior.dtos.LikesBehaviorDto;
import com.usian.model.behavior.dtos.UnLikesBehaviorDto;
import com.usian.model.behavior.pojos.ApUnlikesBehavior;
import com.usian.model.common.dtos.ResponseResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/api/v1")
public class ApUnLikesBehaviorController  implements ApUnLikesBehaviorControllerApi {

    @Autowired
    private ApUnLikesBehaviorService apUnLikesBehaviorService;
//不喜欢的接口
    @PostMapping("/unlike_behavior")
    //点赞与取消点赞的接口
    public ResponseResult like(@RequestBody UnLikesBehaviorDto dto) {
        return apUnLikesBehaviorService.unlike(dto);
    }
//查询喜欢与不喜欢

    @GetMapping("/un_likes_behavior/one")
    @Override
    public ApUnlikesBehavior findUnLikeByArticleIdAndEntryId(@RequestParam("entryId") Integer entryId, @RequestParam("articleId") Long articleId) {
        return apUnLikesBehaviorService.getOne(Wrappers.<ApUnlikesBehavior>lambdaQuery().eq(ApUnlikesBehavior::getArticleId, articleId)
                .eq(ApUnlikesBehavior::getEntryId, entryId));
    }
}